package com.wangyadong.hobby.schedule.jobtask.jvm;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class ListSort {
    public static void main(String[] args) {
		List<Map<String,String>> list = new ArrayList<Map<String,String>>();
		Map<String,String> map1 = new HashMap<String, String>();
		Map<String,String> map2 = new HashMap<String, String>();
		Map<String,String> map3 = new HashMap<String, String>();
		
		map1.put("id", "10");
		map1.put("name", "aa");
		map2.put("id", "13");
		map2.put("name", "bb");
		map3.put("id", "12");
		map3.put("name", "cc");
		list.add(map1);
		list.add(map2);
		list.add(map3);
		System.out.println("排序前："+list);
		Collections.sort(list,new Comparator<Map<String,String>>() {
			@Override
			public int compare(Map<String, String> o1, Map<String, String> o2) {
				// TODO Auto-generated method stub
				return o1.get("id").compareTo(o2.get("id"));
			}
		});
		System.out.println("排序后："+list);
	}
}
